package copyCollectionsDemo;

import java.util.ArrayList;

public class Demo {
	public static void main(String[] args){
		ArrayList<Foo> alist = new ArrayList<Foo>();
		alist.add(new Foo());
		alist.add(new Foo());
		alist.add(new Foo());
		
		ArrayList<Foo> copyAlist = (ArrayList)alist.clone();
		System.out.println(copyAlist);
		System.out.println(alist);
		
		//判断复制的深度
		//浅层 :大的方向，集合的确复制
		System.out.println(alist==copyAlist);
		//深层：小的地方，每一个具体的Foo对象
		System.out.println(alist.get(0)==copyAlist.get(0));
		
	}
}

class Foo{
	int num=2;

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return "num = "+num;
	}
}